package com.wolfking.converter.dropdown;

import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.wolfking.converter.util.ConverterSpringContext;
import com.wolfking.jeesite.entity.Dict;
import com.wolfking.jeesite.service.DictService;

import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

public interface ParameterDropDown {

    Map<String, String> buildParameterDropDown();


    LoadingCache<String, List<Dict>> DICT_CACHE = CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.SECONDS)
            .maximumSize(1000)
            .concurrencyLevel(100)
            .build(new CacheLoader<String, List<Dict>>() {
                @Override
                public List<Dict> load(String dict) {
                    DictService bean = ConverterSpringContext.getBean(DictService.class);
                    return bean.getByType(dict);
                }
            });
}
